import static jdk.nashorn.internal.objects.NativeArray.lastIndexOf;

/**
 * Created by loso on 2017/3/18.
 */
public class _58_LengthOfLastWord {

    public static void main(String[] args) {
        _58_LengthOfLastWord a = new _58_LengthOfLastWord();
        a.lengthOfLastWord("a b");
    }

    public int lengthOfLastWord(String s) {
        s = s.trim();
        int spaceIndex = s.lastIndexOf(' ');
        return s.length() - (spaceIndex==-1?0:spaceIndex+1);

    }
}
